package company.XW;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeSet;

public class XW2A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Long> result = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int apples = sc.nextInt();
            boolean flag = false;
            TreeSet<Long> set = new TreeSet<>();
            for (int j = 0; j < apples; j++) {
                long apple = sc.nextLong();
                if (set.contains(apple)) {
                    result.add((long) 0);
                    flag = true;
                }
                set.add(apple);
            }
            long min = Long.MAX_VALUE;
            long lastNum = -1;
            if (!flag) {
                for (Long l : set) {
                    if (lastNum == -1)
                        lastNum = l;
                    else {
                        min = Math.min(l - lastNum, min);
                        lastNum = l;
                    }
                }
                result.add(min);
            }
        }
        for (Long l : result) {
            System.out.println(l);
        }
    }
}
